package com.ocom.payconfig.controller;

import com.ocom.common.constant.PayConfigUrl;
import com.ocom.common.request.payconfig.PerDiscountLimitRequest;
import com.ocom.common.request.web.ConsumeLimitConfigOnShowRequest;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.common.vo.pay.ConsumeLimitVo;
import com.ocom.payconfig.service.XfUserParamConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 消费限制
 * @Author: 朱晖
 * @Date: 2022/7/14
 **/
@RestController
public class ConsumeLimitController {

	@Autowired
	XfUserParamConfigService xfUserParamConfigService;

	/**
	 * 2.37.获取消费限制参数（getConsumeLimitConfig）
	 */
	@PostMapping(PayConfigUrl.Url_GetConsumeLimitConfig)
	public Result getConsumeLimitConfig(@RequestBody ConsumeLimitConfigOnShowRequest request){
		return ResultUtil.success(xfUserParamConfigService.getConfig(request.getComId(),request));
	}



	/**
	 * 2.38设置消费限制参数（setConsumeLimitConfig）
	 */
	@PostMapping(PayConfigUrl.Url_SetConsumeLimitConfig)
	public Result setConsumeLimitConfig(@RequestBody ConsumeLimitVo consumeLimitVo){
		xfUserParamConfigService.setConfig(consumeLimitVo.getComId(),consumeLimitVo);
		return ResultUtil.success();
	}

	/**
	 * 10.8 个人优惠限制（perDiscountLimit）
	 */
	@PostMapping(PayConfigUrl.Url_perDiscountLimit)
	public Result perDiscountLimit(@RequestBody PerDiscountLimitRequest request){
		return ResultUtil.success(xfUserParamConfigService.perDiscountLimit(request.getComId(),request));
	}


}
